package  
{
	import flash.display.Sprite;
	import flash.text.*;
	import flash.events.Event;
	import Layouts.Game;
	
	public class Timer extends Sprite 
	{
		[Embed(source = "Resources/Texts/kidfont.ttf", fontName = "Kidfont",
		fontStyle = "normal" ,fontWeight = "bold", embedAsCFF= "false") ]
		private static var font:Class;
		private var text_format:TextFormat;
		private var text:TextField;
		
		private var par:Game;
		
		private var timer_cont:Sprite;
		public var timer:Sprite;
		private var timer_shade:Sprite;
		
		public function Timer(parent:Game) {
			addEventListener(Event.ADDED_TO_STAGE, init);
			par = parent;
		}
		
		private function init(e:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			timer_cont = new Sprite;
			timer_cont.graphics.beginFill(0xC99837);
			timer_cont.graphics.drawRoundRect( 0, 0, stage.stageWidth * 34 / 36, stage.stageWidth / 16, stage.stageWidth / 72);
			timer_cont.graphics.endFill();
			addChild(timer_cont);
			
			
			timer_shade = new Sprite;
			timer_shade.graphics.beginFill(0x957C49);
			timer_shade.graphics.drawRect(0, 0, (stage.stageWidth * 34 / 36) * 15 / 16 - stage.stageWidth * 68 / 1152, stage.stageWidth / 36);
			timer_shade.graphics.endFill();
			addChild(timer_shade);
			timer_shade.x = stage.stageWidth * 102 / 1152;
			timer_shade.y = (stage.stageWidth / 32 - stage.stageWidth / 72)
			
			timer = new Sprite;
			timer.graphics.beginFill(0x80FF00);
			timer.graphics.drawRect(0, 0, (stage.stageWidth * 34 / 36) * 15 / 16 - stage.stageWidth * 68 / 1152, stage.stageWidth / 36);
			timer.graphics.endFill();
			addChild(timer);
			timer.x = stage.stageWidth * 102 / 1152;
			timer.y = (stage.stageWidth / 32 - stage.stageWidth / 72);
			
			text_format = new TextFormat();
			text_format.font = "Kidfont";
			text_format.size = 20;
			text = new TextField();
			text.embedFonts= true;
			text.defaultTextFormat = text_format;
			text.selectable = false;
			text.autoSize = TextFieldAutoSize.LEFT;
			text.text = "Tiempo";
			addChild(text);
			text.x = stage.stageWidth * 20 / 1152;
			text.y = (stage.stageWidth / 32 - stage.stageWidth / 72);			
			
		}
		
	}

}